package com.guaoran.source.mybatis.config;


import com.guaoran.source.mybatis.bean.Demo;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : 孤傲然
 * @Description :
 * @date :2018/5/25 23:16
 */
public class MapperRegistory {
    private final static Map<String,MapperData> methodSqlMapping = new HashMap<String, MapperData>();

    public MapperRegistory() {
        methodSqlMapping.put(
                "com.guaoran.source.mybatis.mapper.DemoMapper.queryDemoById",
                new MapperData("select * from demo where id = %d ", Demo.class));
    }

    public static class MapperData<T>{
        private String sql;
        private Class<T> type;

        public MapperData(String sql, Class<T> type) {
            this.sql = sql;
            this.type = type;
        }
        public String getSql() {
            return sql;
        }

        public void setSql(String sql) {
            this.sql = sql;
        }

        public Class<T> getType() {
            return type;
        }

        public void setType(Class<T> type) {
            this.type = type;
        }
    }

    public MapperData get(String nameSpace) {
        return methodSqlMapping.get(nameSpace);
    }

}
